package com.cius.model;

import java.util.List;

/**
 * Created by CiusCheung on 16/9/17.
 */
public class PageModel<T> {
    private int totalRecords;//总记录数
    private List<T> list;//结果集
    private int pageNo;//当前页
    private int pageSize;//每页显示多少条数据

    /**
     * 取得第一页
     * @return 第一页
     */
    public int getTopPageNo(){
        return 1;
    }

    /**
     * 取得下一页
     * @return 下一页
     */
    public int getPreviousPageNo(){
        if(pageNo <=1){
            return 1;
        }
        return pageNo -1;
    }


    /**
     * 取得总页数
     * @return 总页数
     */
    public int getTotalPages(){
        return (totalRecords + pageSize -1)/pageSize;
    }


    public int getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(int totalRecords) {
        this.totalRecords = totalRecords;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
